//
//  AttentionTableViewCell.m
//  Hyatt
//
//  Created by 周游 on 15/5/26.
//  Copyright (c) 2015年 QC.L. All rights reserved.
//

#import "AttentionTableViewCell.h"

@implementation AttentionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubviews];
        
    }
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor grayColor];
    self.backV = [[UIView alloc] init];
    self.backV.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.backV];
    
#warning 周游注 : cell先用默认高度, 再赋值自己指定高度
    // 图片
    self.headIV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"headIV"]];
    [self.backV addSubview:self.headIV];
    
    // 小标题
    self.subjectL = [[UILabel alloc] init];
    [self.backV addSubview:self.subjectL];
    
    // 内容
    self.contentL = [[UILabel alloc] init];
    self.contentL.font = [UIFont systemFontOfSize:13];
    self.contentL.numberOfLines = 2;
    [self.backV addSubview:self.contentL];
    
    // by
    self.byL = [[UILabel alloc] init];
    self.byL.font = [UIFont systemFontOfSize:13];
    [self.backV addSubview:self.byL];
    
    // 标注
    self.markL = [[UILabel alloc] init];
    self.markL.font = [UIFont systemFontOfSize:13];
    [self.backV addSubview:self.markL];
    
    // 时间
    self.timeL = [[UILabel alloc] init];
    self.timeL.font = [UIFont systemFontOfSize:13];
    [self.backV addSubview:self.timeL];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    // 背景视图
    self.backV.frame = CGRectMake(0, kInterval / 2, self.frame.size.width, self.frame.size.height - kInterval);
    
    // 图片
    self.headIV.frame = CGRectMake(kInterval, kInterval, 60, self.backV.frame.size.height  - kInterval * 2);
    // 小标题
    self.subjectL.frame = CGRectMake(self.headIV.frame.origin.x + self.headIV.frame.size.width + kInterval, kInterval, self.frame.size.width - self.headIV.frame.origin.x - self.headIV.frame.size.width - kInterval - 30, 8);
    self.subjectL.text = @"五环之歌";
    
    // 内容
    self.contentL.frame = CGRectMake(self.headIV.frame.origin.x + self.headIV.frame.size.width + kInterval, self.subjectL.frame.origin.y + self.subjectL.frame.size.height + 4, self.subjectL.frame.size.width, (8 + kInterval) * 2);
    self.contentL.text = @"啊~啊~五环!你比四环多一环!啊~啊~五环!你比六环少一环!";
    
    // by
    self.byL.frame = CGRectMake(self.headIV.frame.origin.x + self.headIV.frame.size.width + kInterval, self.backV.frame.size.height - 15 - kInterval, 15, 15);
    self.byL.text = @"by";
    
    // 标注
    self.markL.frame = CGRectMake(self.byL.frame.origin.x + self.byL.frame.size.width + kInterval, self.byL.frame.origin.y, self.subjectL.frame.size.width - self.byL.frame.size.width - self.byL.frame.origin.x - 40 - 10, 15);
    self.markL.text = @"岳云鹏";
    
    // 时间
    self.timeL.frame = CGRectMake(self.backV.frame.size.width - 40 -  kInterval, self.byL.frame.origin.y, 50, self.markL.frame.size.height);
    self.timeL.text = @"3小时前";
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
